let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n96,
  i =
    (this && this.__extends) ||
    ((_n96 = function n(t, e) {
      return (_n96 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
      function (t, e) {
        function o() {
          this.constructor = t;
        }
        _n96(t, e),
          (t.prototype =
            null === e
              ? Object.create(e)
              : ((o.prototype = e.prototype), new o()));
      });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.GridItem = void 0);
var r = t('OperationItem'),
  a = t('ComUtils'),
  s = t('AbsInfo'),
  c = t('TimeMrg'),
  l = t('BattleUtils'),
  u = t('UiEffectCom'),
  h = t('UiWeaponEffect'),
  p = t('BattleMrg'),
  f = t('ResMrg'),
  d = t('UIMrg'),
  g = t('SoundMrg'),
  _ = t('GainCardPanel'),
  y = t('GainCardVo'),
  C = t('MergeMrg'),
  m = t('MathUtils'),
  v = t('CivilizationMrg'),
  b = t('ItemActor'),
  M = t('UIMoneyEffect'),
  I = (function (t) {
    function e(e, o, n) {
      void 0 === o && (o = 0), void 0 === n && (n = 0);
      var i = t.call(this, e) || this;
      return (
        (i.row = 0),
        (i.col = 0),
        (i.canOperate = !0),
        (i._copyCards = []),
        (i.row = o),
        (i.col = n),
        i
      );
    }
    return (
      i(e, t),
      (e.prototype.onInit = function () {
        t.prototype.onInit.call(this),
          (this.type = 1),
          (this._imgSelect = a.default.getNode(this.view, 'imgSelect')),
          (this._imgProgress = a.default.getComponent(
            cc.Sprite,
            this.view,
            'imgProgress'
          )),
          (this._imgDie = a.default.getNode(
            this.view,
            'ItemNode/imgIcon/imgDie'
          )),
          (this._dieMask = a.default.getNode(this.view, 'DieMask')),
          (this._ndBuff = a.default.getNode(this.view, 'Buff')),
          (this._girdlight = a.default.getNode(this.view, 'girdlight')),
          (this._girdlight.active = !1),
          (this._ndBuff.scale = 0.5),
          (this._ndBuff.active = !1),
          (this._imgDie.active = !1),
          this.updateDieMaskDepth();
      }),
      (e.prototype.addCopyCard = function (t) {
        if (null != t) {
          for (var e = 0; e < this._copyCards.length; e++) {
            if (this._copyCards[e] == t) return;
          }
          this._copyCards.push(t), this.refreshCardIcon();
        }
      }),
      (e.prototype.removeCopyCard = function (t) {
        if (null != t)
          for (var e = 0; e < this._copyCards.length; e++) {
            if (this._copyCards[e] == t)
              return this._copyCards.splice(e, 1), void this.refreshCardIcon();
          }
      }),
      (e.prototype.onTouchEvenHandler = function (e) {
        // 检查是否已注册 TOUCH_END 事件监听器 
        if (!this.hasEventListener(cc.Node.EventType.TOUCH_END)) {
          // 检查事件类型、拖拽状态和卡片是否存在
          if (e.type === cc.Node.EventType.TOUCH_END && !this.isDraging && this.card) {
            // 显示卡片获取面板
            d.UIMrg.show(_.GainCardPanel, new y.GainCardVo(0, this.card));
            // 播放点击音效
            g.SoundMrg.click();
          }
        }
        // 调用父类的触摸事件处理方法
        t.prototype.onTouchEvenHandler.call(this, e);
      }),
      (e.prototype.onDataChanged = function () {
        t.prototype.onDataChanged.call(this),
          1 == this.type &&
          (this.data && this.isNormal
            ? h.UiWeaponEffect.show(this)
            : this.emit(p.BattleEvent.SoldierChanged, this),
            this.refreshCardIcon()),
          this.influence();
      }),
      (e.prototype.influence = function () {
        if (this._card) {
          var t = [];
          if (107 == this._card.cardId) t = C.MergeMrg.grids[this.row];
          else if (108 == this._card.cardId)
            for (var e = 0; e < C.MergeMrg.grids.length; e++) {
              t.push(C.MergeMrg.grids[e][this.col]);
            }
          if (this.data)
            for (e = 0; e < t.length; e++) {
              t[e] != this && t[e].addCopyCard(this._card.copyCard);
            }
          else
            for (e = 0; e < t.length; e++) {
              t[e] != this && t[e].removeCopyCard(this._card.copyCard);
            }
        }
        this.refreshCardIcon();
      }),
      (e.prototype.refreshCardIcon = function () {
        this.data
          ? ((this._imgDie.scale = this._imgIcon.node.scale),
            this._ndBuff.setPosition(cc.v2(-40, 40)))
          : ((this._imgSelect.y = 0),
            (this._dieMask.y = 0),
            (this._imgProgress.node.y = 0),
            (this._imgDie.y = 0),
            this._ndBuff.active
              ? cc
                .tween(this._ndBuff)
                .to(0.1, {
                  x: -40,
                  y: 40
                })
                .start()
              : this._ndBuff.setPosition(cc.v2(-40, 40))),
          (null == this.data || 5 != this.data.type) && this._card;
        var t = !1;
        this._card && this.data && 5 != this.data.type
          ? (t = !0)
          : this._copyCards.length > 0 &&
          (null == this.data || 5 != this.data.type) &&
          (t = !0),
          (this._girdlight.active = t);
      }),
      (e.prototype.updateDieMaskDepth = function () {
        this._dieMask &&
          this._itemNode.parent == this._dieMask.parent &&
          (this._dieMask.zIndex = this._itemNode.zIndex + 1);
      }),
      (e.prototype.setRemove = function (t) {
        this.enabled = t;
      }),
      (e.prototype.setSwap = function (t) {
        this.enabled = t;
      }),
      Object.defineProperty(e.prototype, 'selected', {
        get: function get() {
          return this._imgSelect.active;
        },
        set: function set(t) {
          this._imgSelect.active = t;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.refresh = function () {
        t.prototype.refresh.call(this), (this._imgSelect.active = !1);
      }),
      Object.defineProperty(e.prototype, 'soldier', {
        get: function get() {
          return this._soldier;
        },
        set: function set(t) {
          this._soldier = t;
        },
        enumerable: !1,
        configurable: !0
      }),
      Object.defineProperty(e.prototype, 'card', {
        get: function get() {
          return this._card;
        },
        set: function set(t) {
          if (this._card != t) {
            this._card = t;
            var e = a.default.getComponent(
              cc.Sprite,
              this._ndBuff,
              'imgBuffIcon'
            );
            t
              ? f.ResMrg.loadSpriteByAtlas(e, 'Atlas/Battle', t.icon)
              : (e.spriteFrame = null),
              (this._ndBuff.active = null != t),
              this.influence(),
              this.refreshCardIcon(),
              this.onCardChanged();
          }
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onCardChanged = function () { }),
      (e.prototype.startBattle = function () {
        if (this.soldier) {
          if (
            ((this._dieMask.active = !1),
              (this._imgDie.active = !1),
              (this._imgIcon.node.active = !0),
              (this._imgProgress.fillRange = 0),
              (this._imgProgress.node.active = !0),
              this.soldier)
          ) {
            this.soldier.on(
              s.InfoEvent.HPChanged,
              this.onSoldierHpChanged,
              this
            ),
              this.card &&
              (1 == this.card.type
                ? this.soldier.addBuff(this.card)
                : (this.soldier.card = this.card));
            for (var t = 0; t < this._copyCards.length; t++) {
              this.soldier.addBuff(this._copyCards[t]);
            }
            this.onSoldierHpChanged();
          }
          c.TimeMrg.timer.add(this.update, this);
        }
      }),
      (e.prototype.stopBattle = function () {
        this.soldier &&
          ((this._imgProgress.node.active = !1),
            (this.soldier.card = null),
            this.soldier.off(
              s.InfoEvent.HPChanged,
              this.onSoldierHpChanged,
              this
            ),
            this.soldier.revive(),
            c.TimeMrg.timer.remove(this.update, this)),
          (this._dieMask.active = !1),
          (this._imgDie.active = !1),
          (this._imgIcon.node.active = !0),
          this.setGray(!1);
      }),
      (e.prototype.onUpdate = function (e) {
        t.prototype.onUpdate.call(this, e),
          this.soldier &&
          this.soldier.hp > 0 &&
          (this._imgProgress.fillRange =
            this.soldier.attackCD / l.default.AttackCD);
      }),
      (e.prototype.onSoldierHpChanged = function () {
        this.soldier.info.hp <= 0
          ? (this.setGray(!0),
            (this._imgProgress.fillRange = 0),
            c.TimeMrg.timer.remove(this.update, this),
            u.UiEffectCom.show('BrokenEffect', this.view),
            (this._dieMask.active = !0),
            (this._imgDie.active = !0),
            (this._imgIcon.node.active = !1))
          : this._dieMask.active &&
          (this.setGray(!1),
            (this._dieMask.active = !1),
            (this._imgDie.active = !1),
            (this._imgIcon.node.active = !0));
      }),
      (e.prototype.check = function (t) {
        return (
          !!this.canOperate &&
          this._imgSelect.getBoundingBoxToWorld().contains(t)
        );
      }),
      (e.prototype.moveToItem = function (t) {
        if (t) {
          var e = this,
            o = cc.Canvas.instance.node.convertToNodeSpaceAR(
              t.view.convertToWorldSpaceAR(cc.v2(0, 0))
            ),
            n = cc.Canvas.instance.node.convertToNodeSpaceAR(
              this._ndItemNode.convertToWorldSpaceAR(cc.v2(0, 0))
            );
          return (
            (this._ndItemNode.parent = cc.Canvas.instance.node),
            (this._ndItemNode.x = n.x),
            (this._ndItemNode.y = n.y),
            this._ndItemNode.stopAllActions(),
            cc
              .tween(this._ndItemNode)
              .to(0.2, {
                x: o.x,
                y: o.y
              })
              .call(function () {
                (e._isToItem = !1),
                  (e._ndItemNode.parent = e._itemNode),
                  (e._ndItemNode.x = 0),
                  (e._ndItemNode.y = 0),
                  (t.data = e.data),
                  (e.data = null);
              })
              .start(),
            void (this._isToItem = !0)
          );
        }
      }),
      (e.prototype.swapToItem = function (t, e, o) {
        if ((void 0 === e && (e = null), void 0 === o && (o = null), t)) {
          var n = this,
            i = cc.Canvas.instance.node.convertToNodeSpaceAR(
              t.view.convertToWorldSpaceAR(cc.v2(0, 0))
            ),
            r = cc.Canvas.instance.node.convertToNodeSpaceAR(
              this._ndItemNode.convertToWorldSpaceAR(cc.v2(0, 0))
            );
          return (
            (this._ndItemNode.parent = cc.Canvas.instance.node),
            (this._ndItemNode.x = r.x),
            (this._ndItemNode.y = r.y),
            this._ndItemNode.stopAllActions(),
            cc
              .tween(this._ndItemNode)
              .to(0.2, {
                x: i.x,
                y: i.y
              })
              .call(function () {
                (n._isToItem = !1),
                  (n._isDraging = !1),
                  (n._ndItemNode.parent = n._itemNode),
                  (n._ndItemNode.x = 0),
                  (n._ndItemNode.y = 0),
                  e.call(o, n);
              })
              .start(),
            void (this._isToItem = !0)
          );
        }
      }),
      (e.prototype.mergeToItem = function (t, e, o) {
        if (
          (void 0 === e && (e = null),
            void 0 === o && (o = null),
            this.data && t)
        ) {
          var n = this,
            i = cc.Canvas.instance.node.convertToNodeSpaceAR(
              t.view.convertToWorldSpaceAR(cc.v2(0, 0))
            ),
            r = cc.Canvas.instance.node.convertToNodeSpaceAR(
              this._ndItemNode.convertToWorldSpaceAR(cc.v2(0, 0))
            );
          (this._ndItemNode.parent = cc.Canvas.instance.node),
            (this._ndItemNode.x = r.x),
            (this._ndItemNode.y = r.y),
            this._ndItemNode.stopAllActions(),
            cc
              .tween(this._ndItemNode)
              .to(
                0.5,
                {
                  position: i
                },
                {
                  easing: 'quartIn',
                  progress: function progress(t, e, o, n) {
                    var i = e.x - t.x,
                      r = e.y - t.y,
                      a = Math.sin(n * Math.PI);
                    return (
                      (o.x = t.x + i * n),
                      (o.y = t.y + r * n),
                      (o.y += 100 * a),
                      o
                    );
                  }
                }
              )
              .call(function () {
                (n._isToItem = !1),
                  (n._ndItemNode.parent = n._itemNode),
                  (n._ndItemNode.x = 0),
                  (n._ndItemNode.y = 0),
                  (n.data = null),
                  e.call(o, t);
              })
              .start(),
            (this._isToItem = !0);
        }
      }),
      (e.prototype.yieldMoney = function (t) {
        void 0 === t && (t = null);
        var e = t;
        if (null == e && this.data && this.card && 0 == this.card.type) {
          var o = m.default.clamp(
            this.data.level - v.CivilizationMrg.ins.id + 1,
            1,
            6
          ),
            n = this.card;
          (e = 5), Math.random() < 0.01 * n.param[0] && (e += o);
        }
        if (e) {
          var i = new b.ItemActor(e);
          (i.active = !1),
            (i.entity.parent = this.view),
            (i.entity.x = 0),
            (i.entity.y = 0),
            M.UIMoneyEffect.show(i, this.moneyCom),
            (i.entity.parent = null);
        }
      }),
      (e.prototype.onDestroy = function () {
        this._soldier &&
          (this._soldier.targetOff(this), (this._soldier = null)),
          (this.moneyCom = null),
          (this._card = null),
          t.prototype.onDestroy.call(this);
      }),
      e
    );
  })(r.OperationItem);
(o.GridItem = I), console.log('end');
module.exports = e.exports;
